{% extends 'admin_base.html' %}

{% block title2 %}
    插件管理
{% end %}

{% block admin_content %}
<div class="entry-box custom-blog-plugin">
    <h4><strong>插件管理</strong></h4>
    <hr/>
    <p><span class="glyphicon glyphicon-wrench"></span>插件总数：<span class="badge">{{ pager.totalCount }}</span></p>
    <div class="blog-plugin-box">
        <div class="blog-plugin" id="blogPlugin">
            <table class="table table-striped table-hover">
                <thead>
                <tr class="table-header">
                    <th>序号</th>
                    <th>插件名称</th>
                    <th>备注</th>
                    <th>排序</th>
                    <th>启用</th>
                    <th>修改</th>
                    <th>删除</th>
                </tr>
                </thead>
                <tbody>
                {% for plugin in pager.result %}
                    <tr>
                        <td>{{ plugin.order }}</td>
                        <td>{{ plugin.title }}</td>
                        <td>{{ plugin.note }}</td>
                        <td>
                            <a class="btn sort-up" title="升序"
                               href="{{ reverse_url('admin.custom.plugin.update', plugin.id, 'sort-up') }}?pageNo={{pager.pageNo}}">
                                <span class="glyphicon glyphicon-circle-arrow-up"></span>
                            </a>
                            <a class="btn sort-down" title="降序"
                               href="{{ reverse_url('admin.custom.plugin.update', plugin.id, 'sort-down') }}?pageNo={{pager.pageNo}}">
                                <span class="glyphicon glyphicon-circle-arrow-down"></span>
                            </a>
                        </td>
                        <td>
                            {% if plugin.disabled %}
                                <a class="btn btn-sm btn-warning comment-handle-admin enabled-blog-plugin-btn"
                                   title="启用插件"
                                   href="{{ reverse_url('admin.custom.plugin.update', plugin.id, 'enable') }}?pageNo={{pager.pageNo}}">
                                    <span class="glyphicon glyphicon-remove-sign"></span>
                                </a>
                            {% else %}
                                <a class="btn btn-sm btn-success comment-handle-admin disabled-blog-plugin-btn"
                                   title="禁用插件"
                                   href="{{ reverse_url('admin.custom.plugin.update', plugin.id, 'disable') }}?pageNo={{pager.pageNo}}">
                                    <span class="glyphicon glyphicon-ok-sign"></span>
                                </a>
                            {% end %}
                        </td>
                        {% if plugin.content != 'system_plugin' %}
                            <td>
                                <a class="btn" title="修改插件信息"
                                   href="{{ reverse_url('admin.custom.plugin.update', plugin.id, 'edit') }}?pageNo={{pager.pageNo}}">
                                    <span class="glyphicon glyphicon-edit"></span>
                                </a>
                            </td>
                            <td>
                                <a class="btn btn-sm btn-default delete-blog-plugin" title="删除插件"
                                   onclick="delPluginCfm('{{ reverse_url('admin.custom.plugin.update', plugin.id, 'delete') }}?pageNo={{pager.pageNo}}')">
                                    <span class="glyphicon glyphicon-trash"></span>
                                </a>
                            </td>
                        {% else %}
                            <td></td>
                            <td></td>
                        {% end %}
                    </tr>
                {% end %}
                </tbody>
            </table>
        </div>
    </div>
    {% module Template("_macros.html", pager=pager, url=reverse_url('admin.custom.blog_plugin'), params=None) %}
</div>

<!-- 信息删除确认: For delete a plugin confirm -->
<div class="modal fade" id="delPluginCfmModal">
    <div class="modal-dialog">
        <div class="modal-content message_align">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title">确认删除插件？</h4>
            </div>
            <div class="modal-body">
                <p>
                    将该导航删除后不可恢复，您确认要删除吗？
                </p>
                <p>
                    （提示：如果您只是不想显示该插件，可以将其禁用，而不必删除。）
                </p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button id="delPluginCfmClick" class="btn btn-success" data-dismiss="modal">确定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
{% end %}
